<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form action="${pageContext.request.contextPath}/files/FileUpload"
		enctype="multipart/form-data" method="post">
		<input name="filename" type="file" value="tt1" /> <input
			type="submit" value="tijao" />
	</form>
	<form action="${pageContext.request.contextPath}/files/FileUpload2"
		enctype="multipart/form-data" method="post">
		<input name="filename" type="file" value="tt2" /> <input
			type="submit" value="tijao" />
	</form>


	<form id="uploadForm" enctype="multipart/form-data" method="post">
		<input type="file" name="filename">
	</form>
	<br>
	<input type="button" id="upload" value="上传">

	<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
	<script type="text/javascript">
		$(function() {
			$('#upload').click(function() {
				var formData = new FormData($('#uploadForm')[0]);
				$.ajax({
					type : 'POST',
					url : '${pageContext.request.contextPath}/files/FileUpload2',
					data : formData,
					cache : false,
					processData : false,
					contentType : false,

				}).success(function(data) {
					// var result = JSON.parse(data);
					console.log(data);
					alert(data.result);
					console.log(data);
				}).error(function() {
					alert("上传失败");

				});
			});
		});
	</script>
</body>
</html>